[PB-6473]: feat/mta hooks quota#59
Draft
jzunigax2 wants to merge 4 commits into
Draft
Conversation
53b5fcb to
07e4aa6
Compare
- Introduced a new column `network_bucket_id` in the `mail_accounts` table to associate accounts with network buckets. - Updated `AccountService` to create and delete mail buckets via the BridgeClient. - Enhanced unit tests to cover new functionality related to network bucket management. - Modified relevant models and repositories to handle the new `networkBucketId` attribute.
…ices - Introduced a new column `network_bucket_id` in the `mail_addresses` table to associate addresses with network buckets. - Updated `AccountService` to manage network bucket creation and deletion for mail addresses. - Refactored related models and repositories to handle the new `networkBucketId` attribute. - Enhanced unit tests to cover the new functionality and ensure proper handling of network buckets.
- Added MtaHooksModule, MtaHooksController, and MtaHooksService to handle MTA hooks. - Introduced MtaHooksAuthGuard for authentication using basic credentials. - Implemented logic to manage recipient quota checks during the RCPT stage. - Updated configuration to include MTA hooks credentials. - Added unit tests for MtaHooksService and MtaHooksAuthGuard to ensure functionality.
07e4aa6 to
416c9a7
Compare
- Updated MtaHooksService to utilize network bucket ID for quota checks during email processing. - Replaced reportMailUsage with reportBucketUsage in BridgeClient for accurate space tracking. - Enhanced unit tests to reflect changes in recipient context retrieval and bucket usage reporting. - Introduced new UserSpaceSnapshot type for managing bucket space data.
0eb5d20 to
6e5d202
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What
Adds a
POST /mta-hooks/rcptendpoint that Stalwart calls during the SMTP RCPT stage to decide, synchronously, whether to accept or reject an incoming message based on the recipient's combined Drive + Mail storage usage. Also reworks mail quota accounting to be bucket-based: every mail address now owns a dedicated network bucket on the Bridge, and usage is reported/checked per bucket.Why
Inbound mail must respect the user's plan quota. Doing the check at the RCPT stage lets us reject over-quota recipients before the message body is transferred, returning a standard SMTP temporary failure so the sending MTA retries later.
How
RCPT hook (
MtaHooksService.handleRcpt){ userUuid, networkBucketId }contextgetQuota) and reports it to the Bridge bucket-usage endpoint452 4.2.2 "Recipient mailbox is over quota"whentotalUsedSpaceBytes + declaredSize > maxSpaceBytes; otherwise accepts